package day05;

/**
 * @author yzg
 * @desc TODO
 * @date 2025/4/14
 */
public class StringReverse {
    public static void main(String[] args) {
        System.out.println(stringReverse("wasd"));
    }

    public static String stringReverse(String str) {
        char[] charArray = str.toCharArray();
        int left = 0;
        int right = charArray.length - 1;

        while (left < right) {
            char temp = charArray[left];
            charArray[left] = charArray[right];
            charArray[right] = temp;
            left++;
            right--;
        }

        return new String(charArray);
    }
}
